<?php

/**
* @copyright   (C) 2010 iJoomla, Inc. - All rights reserved.
* @license  GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html) 
* @author  iJoomla.com webmaster@ijoomla.com
* @url   http://www.ijoomla.com/licensing/
* the PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript  
* are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0 
* More info at http://www.ijoomla.com/licensing/
*/

	defined( '_JEXEC' ) or die( 'Restricted access' );			
	
	$survey_id = "";
	$page_id = "";
	$question = "";
	$description = "";
	$required = "0";
	$random_a = "";
	$answer_choises = "";
	$question_type = "0";
	$other_field = "0";
	$other_field_title = "";
	$random_c = "0";
	$columns = "";
	$constant = "";
	$minvalue = "";
	$maxvalue = "";
	$nums_menu_heading = "0";
	$menu_heading = "";
	
	$answer_display = "none";
	$another_answer_display = "none";
	$columns_names = "none";
	$constant_num = "none";
	$table_menu_column = "none";
		
	if($this->values != ""){	
		$page_id = $this->values["0"]["page_id"];
		$survey_id = $this->values["0"]["survey_id"];
		$question = $this->values["0"]["title"];
		$description = $this->values["0"]["description"];
		$required = $this->values["0"]["required"];
		$random_a = $this->values["0"]["random_a"];
		$answer_choises = $this->values["0"]["answer_choises"];
		$question_type = $this->values["0"]["question_type"];
		$other_field = $this->values["0"]["other_field"];
		$other_field_title = $this->values["0"]["other_field_title"];
		$random_c = $this->values["0"]["random_c"];		
		$constant = $this->values["0"]["constant"] == "-1" ? "" : $this->values["0"]["constant"];
		$minvalue = $this->values["0"]["minvalue"];
		$maxvalue = $this->values["0"]["maxvalue"];
		$nums_menu_heading = $this->values["0"]["nums_menu_heading"];
		$menu_heading = "";
		
		if($this->columnsValues != ""){			
			$columns = $this->columnsValues["0"]["value"];
		}
		
		if($question_type == "1" || $question_type == "3" || $question_type == "4"){
			$answer_display = "block";
			$another_answer_display = "block";
			$columns_names = "none";
			$constant_num = "none";
		}
		if($question_type == "2" || $question_type == "5" || $question_type == "10" || $question_type == "13"){
			$answer_display = "block";
			$another_answer_display = "none";
			$columns_names = "none";
			$constant_num = "none";
		}
		if($question_type == "6" || $question_type == "7"){
			$answer_display = "block";
			$another_answer_display = "none";
			$columns_names = "block";
			$constant_num = "none";
		}
		if($question_type == "12"){
			$answer_display = "block";
			$another_answer_display = "none";
			$columns_names = "none";
			$constant_num = "block";
		}
		if($question_type == "8"){
			$answer_display = "block";
			$another_answer_display = "none";
			$columns_names = "none";
			$constant_num = "none";
			$table_menu_column = "block";
		}
		
	}	
?>

<div style="overflow:hidden">
	<table width="100%" border="0" cellpadding="3" cellspacing="0" align="left">
		<tr>
			<td width="70%" valign="top" nowrap="nowrap">
				<table>		
					<tr>
						<td align="left" width="10%" nowrap="nowrap"><b><?php echo JText::_("COM_SURVEYS_SURVEY_NAME"); ?>:<span style="color:#FF0000;">*</span></b> </td>
						<td align="left" >
							<?php echo $this->getSurveysList($survey_id, $page_id); ?>
						</td>
					</tr>
					<tr>
						<td align="left" width="10%" nowrap="nowrap"><b><?php echo JText::_("COM_SURVEYS_PAGE_NAME"); ?>:<span style="color:#FF0000;">*</span></b> </td>
						<td align="left" >
							<div id="page_list">							
							<?php 
								if($id != "0"){
									echo $this->getPageList($page_id); 
								}
								else{
									echo '<span style="color:#FF0000;">'.JText::_("COM_SURVEYS_SELECT_A_SURVEY_FIRST").'</span>';
								}
							?>
							</div>
						</td>
					</tr>
					<tr>
						<td align="left" width="10%" nowrap="nowrap"><b><?php echo JText::_("COM_SURVEYS_PAGE_QUESTION"); ?>:<span style="color:#FF0000">*</span></b> </td>
						<td align="left" >
							<textarea name="title" rows="3" cols="55"><?php echo $question; ?></textarea>
						</td>
					</tr> 
					<tr>
						<td align="left" width="10%" nowrap="nowrap"><b><?php echo JText::_("COM_SURVEYS_DESCRIPTION"); ?>:</b> </td>
						<td align="left" >
							<textarea name="description" rows="3" cols="55"><?php echo $description; ?></textarea>
						</td>
					</tr>
					<tr>
						<td align="left" width="10%"><b><?php echo JText::_("COM_SURVEYS_REQUIRED"); ?>:</b> </td>
						<td align="left" >
							<table>
								<tr>
									<td>
										<table>
											<tr>
												<td>
													<input type="radio" name="required" value="1" <?php if($required == "1"){echo 'checked="checked"';} ?> />
												</td>
												<td>	
													<?php echo JText::_("JYES"); ?>
												</td>
											</tr>
										</table>			
									</td>
									<td>
										<table>
											<tr>
												<td>	
													<input type="radio" name="required" value="0" <?php if($required == "0"){echo 'checked="checked"';} ?> />
												</td>
												<td>	
													<?php echo JText::_("JNO"); ?>
												</td>
											</tr>
										</table>			
									</td>
								</tr>
							</table>		
						</td>
					</tr>
					<tr>
						<td></td>
						<td align="left" >
							<input type="checkbox" name="random_a" value="1" <?php if($random_a == "1"){echo 'checked="checked"';} ?> />&nbsp;<b><?php echo JText::_("COM_SURVEYS_RANDOM_ANSWER"); ?></b>
						</td>
					</tr>
					<tr>
						<td><b><?php echo JText::_("COM_SURVEYS_QUESTION_TYPE"); ?><span style="color:#FF0000">*</span></b></td>
						<td align="left" >
							<?php echo $this->getQuestionType($question_type); ?>
						</td>
					</tr>
					<tr>
						<td colspan="2">			
						<div id="div_answer" style="display:<?php echo $answer_display; ?>;">
							<table width="80%">
								<tr>
									<td width="25%"><b><?php echo JText::_("COM_SURVEYS_ANSWEWR_CHOICES"); ?><br/></b><?php echo JText::_("COM_SURVEYS_ANSWEWR_CHOICES_DETAILS"); ?></td>
									<td align="left" >
										<textarea name="answer" cols="40" rows="7"><?php echo $answer_choises; ?></textarea>
									</td>
								</tr>
							</table>
						</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">			
						<div id="div_another_answer" style="display:<?php echo $another_answer_display; ?>;">
							<table width="65%">
								<tr>
									<td width="20%"><b><?php echo JText::_("COM_SURVEYS_ANOTHER_ANSWEWR"); ?><br/></td>
									<td align="left" >
										<table>
											<tr>
												<td>
													<table>
														<tr>
															<td>												
																<input type="radio" name="other_field" value="1" <?php if($other_field == "1"){echo 'checked="checked"';} ?> />																
															</td>
															<td>	
																<?php echo JText::_("JYES"); ?>
															</td>
														</tr>
													</table>			
												</td>
												<td>
													<table>
														<tr>
															<td>	
																
															</td>
															<td>
																<input type="radio" name="other_field" value="0" <?php if($other_field == "0"){echo 'checked="checked"';} ?> />	
																<?php echo JText::_("JNO"); ?>
															</td>
														</tr>
													</table>			
												</td>
											</tr>
										</table>			
									</td>
								</tr>
								<tr>
									<td><?php echo JText::_("COM_SURVEYS_OTHER_FIELD_TITLE"); ?></td>
									<td align="left" >
										<input type="text" name="other_field_title" value="<?php echo $other_field_title; ?>"/>
									</td>
								</tr>
							</table>
						</div>
						</td>
					</tr>		
					<tr>
						<td colspan="2">			
						<div id="div_columns_names" style="display:<?php echo $columns_names; ?>;">
							<table width="80%">
								<tr>
									<td width="25%"><b><?php echo JText::_("COM_SURVEYS_COLUMNS_NAMES"); ?>:<span style="color:#FF0000">*</span></b><br/><?php echo JText::_("COM_SURVEYS_COLUMNS_DETAILS"); ?></td>
									<td align="left" >
										<input type="checkbox" name="random_c" value="0" <?php if($random_c == "1"){echo 'checked="checked"';} ?> /><b>&nbsp;<?php echo JText::_("COM_SURVEYS_RANDOM_COLUMNS"); ?><b><br/>
										<textarea name="columns" rows="4" cols="40"><?php echo $columns; ?></textarea>
									</td>
								</tr>					
							</table>
						</div>
						</td>
					</tr>
					<tr>
						<td colspan="2">			
						<div id="div_constant" style="display:<?php echo $constant_num; ?>;">
							<table>
								<tr >
									<td align="left">
										<input type="text" name="constant" maxlength="10" size="5" value="<?php echo $constant; ?>"/>
									</td>
									<td>
										<?php echo JText::_("COM_SURVEYS_CONSTANT"); ?>
									</td>
								</tr>
								<tr>
									<td align="left" colspan="2">
										<?php echo JText::_("COM_SURVEYS_MIN_VALUE");?><input type="text" name="minvalue" maxlength="10" size="5" value="<?php echo $minvalue; ?>"/>
										<?php echo JText::_("COM_SURVEYS_MAX_VALUE");?><input type="text" name="maxvalue" maxlength="10" size="5" value="<?php echo $maxvalue; ?>"/>
									</td>
								</tr>					
							</table>
						</div>
						</td>
					</tr>						
				</table>
			</td>
			<td valign="top" nowrap="nowrap">			
				<div id="table_menu_column" style="display:<?php echo $table_menu_column; ?>;">
					<table>
						<tr>
							<td valign="top">
								<b><?php echo JText::_("COM_SURVEYS_MENU"); ?></b><?php echo $this->getMenusNumber($nums_menu_heading); ?><br/>
								<?php echo JText::_("COM_SURVEYS_MENU_DETAILS"); ?>
							</td>
						</tr>
						<?php
							echo $this->printMenusList($nums_menu_heading);
						?>
					</table>
				</div>
			</td>
		</tr>
	</table>		
</div>